#!/bin/bash

msv='java -jar /opt/local/share/java/msv.jar'

for i in `ls test`; do
	xsd=resources/xsd/$i.xml
	if [ ! -f $xsd ]; then
		echo "No xsd $xsd"
		continue;
	fi

	for t in `ls test/$i/good`; do
		xml=test/$i/good/$t
		validate="$msv -warning -standalone $xsd $xml"
		if [[ ! `$validate | grep "is valid"` ]]; then
			echo "$i/$t was suppose to validate:"
			$validate
		else
			echo "OKAY: $i/$t validated"
		fi
	done

	for t in `ls test/$i/bad`; do
		xml=test/$i/bad/$t
		validate="$msv -warning -standalone $xsd $xml"
		if [[ ! `$validate | grep "is NOT valid"` ]]; then
			echo "FAIL: $i/$t was not suppose to validate:"
			$validate
		else
			echo "OKAY: $i/$t did not validate "
		fi
	done
done
